<?php

declare(strict_types=1);

namespace App\CustHub\Service;

use App\CustHub\Mapper\ChUserMapper;
use App\Setting\Service\SettingConfigService;
use Hyperf\Di\Annotation\Inject;
use Mine\Abstracts\AbstractService;

class PayService extends AbstractService
{
    #[Inject]
    protected SettingConfigService $settingConfigService;

    #[Inject]
    protected ChUserMapper $userMapper;

    public function getConfig(array $data): array
    {
        $alipayPayStatus = $this->settingConfigService->getConfigByKey('alipay_pay_status')['value'] ?? "false";
        $wechatPayStatus = $this->settingConfigService->getConfigByKey('wechat_pay_status')['value'] ?? "false";
        $transferStatus = $this->settingConfigService->getConfigByKey('transfer_status')['value'] ?? "false";

        $user = $this->userMapper->findById($data['uid']);

        return [
            'money' => $user->money,
            'alipay_pay_status' => $alipayPayStatus == 'true',
            'wechat_pay_status' => $wechatPayStatus == 'true',
            'transfer_status' => $transferStatus == 'true',
        ];
    }
}